﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using Microsoft.Windows.Controls.Ribbon;
using ChoDiaOc_HK_WPF.Views.QuanLy;
using ChoDiaOc_HK_WPF.Models;
using ChoDiaOc_HK_WPF.Views.CongCong;
using ChoDiaOc_HK_WPF.Views.GiaHanDichVu;

namespace ChoDiaOc_HK_WPF.Views {
    /// <summary>
    /// Interaction logic for ManHinhChinh.xaml
    /// </summary>
    /// 

    public partial class ManHinhChinh : RibbonWindow {

        private About aboutControl = null;

        public About AboutControl {
            get {
                if (aboutControl == null) {
                    aboutControl = new About();
                } return aboutControl;
            }
        }

        private ManHinhTiepNhanDangKy tiepNhanDangKyScreen = null;

        public ManHinhTiepNhanDangKy TiepNhanDangKyScreen {
            get {
                if (tiepNhanDangKyScreen == null) {
                    tiepNhanDangKyScreen = new ManHinhTiepNhanDangKy();
                } return tiepNhanDangKyScreen;
            }
        }

        private ManHinhChupAnh chupAnhScreen = null;

        public ManHinhChupAnh ChupAnhScreen {
            get {
                if (chupAnhScreen == null) {
                    chupAnhScreen = new ManHinhChupAnh();
                } return chupAnhScreen;
            }
        }

        private ManHinhQuanLy quanLyScreen = null;

        public ManHinhQuanLy QuanLyScreen {
            get {
                if (quanLyScreen == null) {
                    quanLyScreen = new ManHinhQuanLy();
                } return quanLyScreen;
            }
        }

        private ManHinhBaoBieu baoBieuScreen = null;

        public ManHinhBaoBieu BaoBieuScreen {
            get {
                if (baoBieuScreen == null) {
                    baoBieuScreen = new ManHinhBaoBieu();
                } return baoBieuScreen;
            }
        }

        private DangNhap dangNhapControl = null;

        public DangNhap DangNhapControl {
            get {
                if (dangNhapControl == null) {
                    dangNhapControl = new DangNhap();
                } return dangNhapControl;
            }
        }

        private BangGia bangGiaControl = null;

        public BangGia BangGiaControl {
            get {
                if (bangGiaControl == null) {
                    bangGiaControl = new BangGia();
                } return bangGiaControl;
            }
        }

        private DanhSachDiaOcRaoBan danhSachDiaOcRaoBanControl = null;

        public DanhSachDiaOcRaoBan DanhSachDiaOcRaoBanControl {
            get {
                if (danhSachDiaOcRaoBanControl == null) {
                    danhSachDiaOcRaoBanControl = new DanhSachDiaOcRaoBan();
                } return danhSachDiaOcRaoBanControl;
            }
        }

        private LienHe lienHeControl = null;

        public LienHe LienHeControl {
            get {
                if (lienHeControl == null) {
                    lienHeControl = new LienHe();
                }
                return lienHeControl;
            }
        }

        private GiaHanDichVu.GiaHanDichVu giaHanDangKyControl = null;

        public GiaHanDichVu.GiaHanDichVu GiaHanDangKyControl {
            get {
                if (giaHanDangKyControl == null) {
                    giaHanDangKyControl = new GiaHanDichVu.GiaHanDichVu();
                }
                return giaHanDangKyControl;
            }
        }

        private GiaHanDichVu.HuyDichVu huyDangKyControl = null;

        public GiaHanDichVu.HuyDichVu HuyDangKyControl {
            get {
                if (huyDangKyControl == null) {
                    huyDangKyControl = new GiaHanDichVu.HuyDichVu();
                }
                return huyDangKyControl;
            }
        }

        private KhachHang.DanhSachDiaOcDaDangKy danhSachDiaOcDaDangKyControl = null;

        public KhachHang.DanhSachDiaOcDaDangKy DanhSachDiaOcDaDangKyControl {
            get {
                if (danhSachDiaOcDaDangKyControl == null) {
                    danhSachDiaOcDaDangKyControl = new KhachHang.DanhSachDiaOcDaDangKy();
                }
                return danhSachDiaOcDaDangKyControl;
            }
            set { danhSachDiaOcDaDangKyControl = value; }
        }

        private KhachHang.XemNoiDungQuangCao xemNoiDungQuangCaoControl = null;

        public KhachHang.XemNoiDungQuangCao XemNoiDungQuangCaoControl {
            get {
                if (xemNoiDungQuangCaoControl == null) {
                    xemNoiDungQuangCaoControl = new KhachHang.XemNoiDungQuangCao();
                }
                return xemNoiDungQuangCaoControl;
            }
            set { xemNoiDungQuangCaoControl = value; }
        }

        private KhachHang.BangGiaDichVu bangGiaDichVuControl = null;

        public KhachHang.BangGiaDichVu BangGiaDichVuControl {
            get {
                if (bangGiaDichVuControl == null) {
                    bangGiaDichVuControl = new KhachHang.BangGiaDichVu();
                }
                return bangGiaDichVuControl;
            }
            set { bangGiaDichVuControl = value; }
        }


        public ManHinhChinh() {
            InitializeComponent();

            // Insert code required on object creation below this point

            App.ManHinhChinh = this;

            // Log Out

            DoLoggedOut();
        }

        private void Window_Loaded(object sender, RoutedEventArgs e) {

            gridMain.Children.Add(AboutControl);
        }

        private void btnTiepNhanDangKy_Click(object sender, RoutedEventArgs e) {
            TiepNhanDangKyScreen.ShowDialog();
        }

        private void btnDangNhap_Click(object sender, RoutedEventArgs e) {
            gridMain.Children.Clear();
            gridMain.Children.Add(DangNhapControl);
        }

        public void DoLoggedIn(String role) {
            // Tien hanh hien/an cac thanh phan giao dien tuy vao quyen dang nhap

            btnDangXuat.Visibility = Visibility.Visible;
            btnDangNhap.Visibility = Visibility.Collapsed;

            switch (role) {
                case "Admin":
                    btnQuanLy.Visibility = Visibility.Visible;
                    break;
                case "Saler":
                    btnTiepNhanDangKy.Visibility = Visibility.Visible;
                    btnGiaHanDangKy.Visibility = Visibility.Visible;
                    btnHuyDangKy.Visibility = Visibility.Visible;
                    btnXemBangGia.Visibility = Visibility.Visible;
                    groupTiepNhanDangKy.Visibility = Visibility.Visible;
                    break;
                case "Reporter":
                    btnBaoBieu.Visibility = Visibility.Visible;
                    groupBaoBieu.Visibility = Visibility.Visible;
                    break;
                case "Photographer":
                    btnChupAnh.Visibility = Visibility.Visible;
                    groupTiepNhanDangKy.Visibility = Visibility.Visible;
                    break;
                case "Customer":
                    btnDanhSachDiaOc.Visibility = Visibility.Visible;
                    btnXemBangGia.Visibility = Visibility.Visible;
                    btnXemQuangCaoDaDangKy.Visibility = Visibility.Visible;
                    groupKhachHang.Visibility = Visibility.Visible;
                    break;
            }

            gridMain.Children.Clear();
            gridMain.Children.Add(AboutControl);

        }

        public void DoLoggedOut() {
            // Tien hanh hien/an cac thanh phan giao dien khi logout
            btnDangNhap.Visibility = Visibility.Visible;

            btnTiepNhanDangKy.Visibility = Visibility.Collapsed;
            btnGiaHanDangKy.Visibility = Visibility.Collapsed;
            btnHuyDangKy.Visibility = Visibility.Collapsed;

            btnDangXuat.Visibility = Visibility.Collapsed;
            btnDanhSachDiaOc.Visibility = Visibility.Collapsed;
            btnChupAnh.Visibility = Visibility.Collapsed;
            btnQuanLy.Visibility = Visibility.Collapsed;
            btnXemBangGia.Visibility = Visibility.Collapsed;
            btnXemQuangCaoDaDangKy.Visibility = Visibility.Collapsed;
            groupKhachHang.Visibility = Visibility.Collapsed;
            groupTiepNhanDangKy.Visibility = Visibility.Collapsed;
            btnBaoBieu.Visibility = Visibility.Collapsed;
            groupBaoBieu.Visibility = Visibility.Collapsed;

        }

        private void btnDangXuat_Click(object sender, RoutedEventArgs e) {
            DoLoggedOut();
            gridMain.Children.Clear();
            gridMain.Children.Add(AboutControl);
        }

        private void btnAbout_Click(object sender, RoutedEventArgs e) {
            gridMain.Children.Clear();
            gridMain.Children.Add(AboutControl);
        }

        private void btnThoat_Click(object sender, RoutedEventArgs e) {
            this.Close();
        }

        private void btnXemDanhSachDiaOcDangRaoBan_Click(object sender, RoutedEventArgs e) {
            gridMain.Children.Clear();
            gridMain.Children.Add(DanhSachDiaOcRaoBanControl);
        }

        private void btnLienHe_Click(object sender, RoutedEventArgs e) {
            gridMain.Children.Clear();
            gridMain.Children.Add(LienHeControl);
        }

        private void btnXemBangGiaCC_Click(object sender, RoutedEventArgs e) {
            gridMain.Children.Clear();
            gridMain.Children.Add(BangGiaControl);
        }

        private void btnGiaHanDangKy_Click(object sender, RoutedEventArgs e) {
            gridMain.Children.Clear();
            gridMain.Children.Add(GiaHanDangKyControl);
        }

        private void btnHuyDangKy_Click(object sender, RoutedEventArgs e) {
            gridMain.Children.Clear();
            gridMain.Children.Add(HuyDangKyControl);
        }

        private void btnChupAnh_Click(object sender, RoutedEventArgs e) {
            ChupAnhScreen.ShowDialog();
        }

        private void btnQuanLy_Click(object sender, RoutedEventArgs e) {
            QuanLyScreen.ShowDialog();
        }

        private void btnBaoBieu_Click(object sender, RoutedEventArgs e) {
            BaoBieuScreen.ShowDialog();
        }

        private void btnDanhSachDiaOc_Click(object sender, RoutedEventArgs e) {
            gridMain.Children.Clear();
            gridMain.Children.Add(DanhSachDiaOcDaDangKyControl);
        }

        private void btnXemBangGia_Click(object sender, RoutedEventArgs e) {
            gridMain.Children.Clear();
            gridMain.Children.Add(BangGiaDichVuControl);
        }

        private void btnXemQuangCaoDaDangKy_Click(object sender, RoutedEventArgs e) {
            gridMain.Children.Clear();
            gridMain.Children.Add(XemNoiDungQuangCaoControl);
        }
    }
}
